package cn.study.luckydomain.User;

import cn.hutool.crypto.digest.MD5;
import lombok.Getter;
import lombok.Setter;
import org.apache.ibatis.annotations.Select;

@Getter
public class Password {
    private EncryptionPassword encryptionPassword;
    public Password(String password){
        String password1=getEncryptionPassword(password);
        encryptionPassword=new EncryptionPassword(password1);
    }
    public Password(){
        encryptionPassword=new EncryptionPassword();
    }
    public String getEncryptionPassword(String password){
        return MD5.create().digestHex16(password);
    }
    @Getter
    @Setter
    public static class EncryptionPassword{
        private String password;
        public EncryptionPassword(){};
        public EncryptionPassword(String password){
            this.password=password;
        }
    }
    public Boolean isEqual(String password){
        return this.encryptionPassword.password.equals(getEncryptionPassword(password));
    }
}
